// pages/search/search.js
let app = getApp();
let searchWords;
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    inputwords: "",
    articleNum: 0,
    shopNum: 0,
    goodsNum: 0,
    historyList:[{
      id:0,
      name:"痘痘肌肤"
    },
      {
        id: 0,
        name: "痘痘肌肤"
      },
      {
        id: 1,
        name: "面膜"
      },
      {
        id: 2,
        name: "爽肤水"
      },
      {
        id: 3,
        name: "今天的特价商品"
      }, {
        id: 4,
        name: "痘痘肌肤"
      },
      {
        id: 5,
        name: "痘痘肌肤"
      },
      {
        id: 6,
        name: "面膜"
      },
      {
        id: 7,
        name: "爽肤水"
      },
      {
        id: 8,
        name: "今天的特价商品"
      },

    ],
     hotList: [{
      id: 0,
      name: "痘痘肌肤"
    },
    {
      id: 0,
      name: "痘痘肌肤"
    },
    {
      id: 1,
      name: "面膜"
    },
    {
      id: 2,
      name: "爽肤水"
    },
    {
      id: 3,
      name: "今天的特价商品"
    }, {
      id: 4,
      name: "痘痘肌肤"
    },
    {
      id: 5,
      name: "痘痘肌肤"
    },
    {
      id: 6,
      name: "面膜"
    },
    {
      id: 7,
      name: "爽肤水"
    },
    {
      id: 8,
      name: "今天的特价商品"
    },

    ],
    suggestList: [{
      id: 0,
      name: "痘痘肌肤"
    },
    {
      id: 0,
      name: "痘痘肌肤"
    },
    {
      id: 1,
      name: "面膜"
    },
    {
      id: 2,
      name: "爽肤水"
    }
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },
  //搜索框失去焦点
  searchBlur:function(event){
      console.log(event.detail);
      searchWords=event.detail.value;
      var that=this;
      that.setData({
        searchWords:searchWords
      })
  },
  //搜索框输入时
  searchInput:function(event){
      var that=this;
      console.log(event.detail);
      var inputwords=event.detail.value;//搜索框内输入的文字
    if (inputwords){
      that.setData({
        suggestflag:true
      })
    }else{
      that.setData({
        suggestflag: false
      })
    }
      //测试数据
      this.setData({
        inputwords:inputwords,
        articleNum:45,
        shopNum:30,
        goodsNum:50
      })

  },
  searchBtn:function(e){
    console.log(e);
    searchWords=e.currentTarget.dataset.searchWords;//访问接口，传值用

    
      //请求接口，跳转页面
    // wx.navigateTo({
    //   url: '/pages/searchResult/searchResult',
    // })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})